<?php 
session_start();
if (isset($_POST['p51']) && isset($_SESSION['openid'])){
    $openid=$_SESSION['openid'];
    $w1=$_POST['p51'];
    $w2=$_POST['p52'];
    $w3=$_POST['p53'];
    $w4=$_POST['p54'];
    $w5=$_POST['p55'];
    
    $checkData='';
    if (!empty($w1)){
        $checkData='1';
    }
    if (!empty($w2)){
        $checkData='1';
    }
    if (!empty($w3)){
        $checkData='1';
    }
    if (!empty($w4)){
        $checkData='1';
    }
    if (!empty($w5)){
        $checkData='1';
    }
     
	include_once("../c/config.php");
	$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
	if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
	
	if (!empty($checkData)){
	    $sql="select id from p5new where openid='".$openid."'  limit 0, 1";
	    $query=$mysqli->query($sql);
	    if($query->num_rows>0){
	        $mysqli->query("update `p5new` set w1='".$w1."',w2='".$w2."',w3='".$w3."',w4='".$w4."',w5='".$w5."',`createtime`='".date("Y-m-d H:i:s")."' where openid='".$openid."' ");
	    }else{
	        $mysqli->query("INSERT INTO `p5new` (`openid`,`w1`,`w2`,`w3`,`w4`,`w5`,`createtime`) VALUES ('".$openid."','".$w1."','".$w2."','".$w3."','".$w4."','".$w5."','".date("Y-m-d H:i:s")."') ");
	    }
	}
	 
    echo json_encode(array('s'=>'ok'));
    $mysqli->close();

}else{
    $msg=json_encode(array('s'=>'n'));
}
?>